import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'file-saver'
import '@/assets/jquery.wordexport.js'
Vue.config.productionTip = false
import mavonEditor from 'mavon-editor';
import 'mavon-editor/dist/css/index.css';
import axios from 'axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
Vue.use(Avue);
Vue.use(ElementUI);
const instance=axios.create({
  baseURL: process.env.VUE_APP_URL,
  headers: {'Authorization': "Bearer "+sessionStorage.getItem('token')}
})

Vue.prototype.$httpajax=instance
window.axios=instance
//use
Vue.use(mavonEditor);
new Vue({
  router,
  store,
  render: h => h(App),
  async created(){
    if(sessionStorage.getItem('token')){
        
      //获取用户信息 是否有权限
      const user= await this.$httpajax.post("auth/getInfo")
      //添加用户名 
      this.$store.commit('setuserInfo',user.data.data)
      this.$router.push("/home")

    }
    else{
      this.$router.push("/")
    }
  }
}).$mount('#app')
